package com.studiofortress.sf.util.collections;

/**
 * Collections that implement this interface can have IteratorCallback's passed
 * into them in order to iterate over all of their values.
 * 
 * @author Joseph Lenton - JosephLenton@StudioFortress.com
 */
public interface CallbackIterable<A>
{
    /**
     * The callback given has it's iterate method called with implementing
     * classes of this interface.
     * @param callback The iterator to use when iterating, cannot be null.
     */
    public abstract void iterate(CallbackIterator<A> callback);

    /**
     * The callback given has it's iterate method called with implementing
     * classes of this interface. However this can also be pre-empted and
     * stopped by calling the stopIterator() method on the callback.
     *
     * Implementing classes are required to call startIteration() before using
     * the iterator.
     * 
     * @param callback The iterator to use when iterating, cannot be null.
     */
    public abstract void iteratePartial(CallbackPartialIterator<A> callback);
}
